/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package copyproject.copyjob;

import copyproject.filecopier.CopyJob;
import copyproject.filecopier.FileCopier;
import copyproject.filecopier.Source;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author a000cpu
 */
public class CopyJobApp {

    private static final Logger LOGGER = Logger.getLogger(CopyJobApp.class.getName());

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

	// test run
	final FileCopier fileCopier = new FileCopier();

	try {

	    long currentTimeMillisStart = System.currentTimeMillis();

	    //CopyJob unixCopyJob = createCopyJobUnix();

	    fileCopier.copy(createCopyJobWindows());


	    long currentTimeMillisEnd = System.currentTimeMillis();

	    long tempsEcoule = (currentTimeMillisEnd - currentTimeMillisStart) / 1000;

	    long tempsEcouleHeures = tempsEcoule / (60 * 60);

	    long tempsEcouleHeuresRes = tempsEcoule % (60 * 60);

	    long tempsEcouleMin = tempsEcouleHeuresRes / 60;

	    long tempsEcouleMinRes = tempsEcouleHeuresRes % 60;

	    long tempsEcouleSec = tempsEcouleMinRes;

	    System.out.println();

	    System.out.println("Copie Termine");

	    System.out.print("Temps ecoule:" + String.valueOf(tempsEcouleHeures)
		    + "h");
	    System.out.print(String.valueOf(tempsEcouleMin) + "m");
	    System.out.print(String.valueOf(tempsEcouleSec) + "s");

	} catch (Exception ex) {
	    LOGGER.log(Level.SEVERE, null, ex);
	}


    }

    private static CopyJob createCopyJobUnix() {

	// Unix example
	Source[] sources = new Source[]{
	    // all files from directory /home/user/source1/
	    new Source("/home/kholmes/test/source1/"),
	    // all *.java files from directory
	    // /home/user/source2/
	    new Source("/home/kholmes/test/source2/")};
	String[] destinations = new String[]{
	    "/home/kholmes/test/destination1",
	    "/home/kholmes/test/destination2"};

	return new CopyJob(sources, destinations);
    }

    private static CopyJob createCopyJobWindows() {

	Source[] sources = new Source[]{
	    new Source(EnumCopyFiles.PATHNAME_SRC_DIR_PROJET_BC.getNomfich())};

	String[] destinations = new String[]{
	    EnumCopyFiles.PATHNAME_DEST_DIR_PROJET_BC.getNomfich()};

	return new CopyJob(sources, destinations);

    }
}
